﻿using Ardalis.Specification;
using Domain.Entities;

namespace Domain.Specifications
{
    public class UserSpecs
    {
        /// <summary>
        /// 手机号
        /// </summary>
        public class UserByPhoneNumberSpec : Specification<User>
        {
            public UserByPhoneNumberSpec(string phoneNumber)
            {
                Query.Where(user => user.PhoneNumber.Value == phoneNumber);
            }
        }

        /// <summary>
        /// 姓名
        /// </summary>
        public class UsersByNickNameContainsSpec : Specification<User>
        {
            public UsersByNickNameContainsSpec(string partialName)
            {
                Query.Where(user => user.NickName.Value.Contains(partialName));
            }
        }

        public class UsersByIdsSpec : Specification<User>
        {
            public UsersByIdsSpec(ICollection<Guid> ids)
            {
                Query.Where(user => ids.Contains(user.Id));
            }
        }

        public class UserByCollegeNamesSpec : Specification<User>
        {
            public UserByCollegeNamesSpec(params string[] collegeNames)
            {
                Query.Where(user => collegeNames.Contains(user.AcademicInfo.CollegeName));
            }
        }

        public class UserByMajorNamesSpec : Specification<User>
        {
            public UserByMajorNamesSpec(string majorNames)
            {
                Query.Where(user => majorNames.Contains(user.AcademicInfo.MajorName));
            }
        }

    }
}
